package com.sg.service.biz.app.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.base.app.req.*;
import com.sg.dto.biz.app.req.*;
import com.sg.dto.biz.app.res.*;
import com.sg.service.biz.app.TargetCycleService;
import com.sg.common.exception.Assert;
import com.wicket.okrapp.dal.po.mbg.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class CycleConfServiceImpl
        implements com.wicket.okrapp.biz.service.CycleConfService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MOmsEvaCycleConfService mOmsEvaCycleConfService;
    @Resource
    private MOmsCycleTimeRuleService mOmsCycleTimeRuleService;
    @Resource
    private NbCycleConf nbCycleConf;
    @Resource
    private MOmsCycleService mOmsCycleService;
    @Resource
    private MOmsExecuteCycleStageService mOmsExecuteCycleStageService;
    @Resource
    private MOmsCycleTypeService mOmsCycleTypeService;
    @Resource
    private TargetCycleService targetCycleService;
//@Resource
    //private MCustomFields2Service mCustomFields2Service;

    /**
     * D3-2查周期配置详情[2556]
     * gen by moon at 10/12/2022, 11:44:59 PM
     */
    @Trace(operationName = "D3-2查周期配置详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryCycleConfDetailRespDto queryCycleConfDetail(QueryCycleConfDetailReqDto reqDto) {


        OmsEvaCycleConf omsEvaCycleConf_1 = null;
        OmsCycleType omsCycleType_1 = null;
//步骤0: 3-2-08查周期配置详情 - queryCycleConfDetail
        OmsEvaCycleConf omsEvaCycleConf = null;
        QueryCycleConfDetailReq queryCycleConfDetailReq = new QueryCycleConfDetailReq();
        if (reqDto != null) {
            queryCycleConfDetailReq.setCycleConfId(reqDto.getCycleConfId());//SimpleFieldAssign//sourceId:79121_1
            queryCycleConfDetailReq.setCycleConfCode(reqDto.getCycleConfCode());//SimpleFieldAssign//sourceId:103366_1
            queryCycleConfDetailReq.setCycleTypeCode(reqDto.getCycleTypeCode());//SimpleFieldAssign//sourceId:79022_1
            queryCycleConfDetailReq.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:103365_1
            queryCycleConfDetailReq.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:79023_1
        }

        /*3-2-08查周期配置详情[2360]   */

        omsEvaCycleConf = mOmsEvaCycleConfService.queryCycleConfDetail(queryCycleConfDetailReq);


        omsEvaCycleConf_1 = omsEvaCycleConf;

//步骤1: 3-4-01查周期类型详情 - queryCycleTypeDetail
        OmsCycleType omsCycleType = null;
        if (omsEvaCycleConf != null) {
            QueryCycleTypeDetailReq queryCycleTypeDetailReq = new QueryCycleTypeDetailReq();
            if (omsEvaCycleConf != null) {
                queryCycleTypeDetailReq.setCycleTypeCode(omsEvaCycleConf.getCycleTypeCode());//SimpleFieldAssign//sourceId:376543_1
            }

            /*3-4-01查周期类型详情[1881]   */
            Assert.isNull(queryCycleTypeDetailReq.getCycleTypeCode(), "D3-2查周期配置详情-3-4-01查周期类型详情-周期类型标识不能为空", false);
            omsCycleType = mOmsCycleTypeService.queryCycleTypeDetail(queryCycleTypeDetailReq);


            omsCycleType_1 = omsCycleType;
        }

        QueryCycleConfDetailRespDto retData = new QueryCycleConfDetailRespDto();
        if (omsEvaCycleConf_1 != null) {
            retData.setCycleConfId(omsEvaCycleConf_1.getCycleConfId());//SimpleFieldAssign//sourceId:79038_1
            retData.setCycleConfCode(omsEvaCycleConf_1.getCycleConfCode());//SimpleFieldAssign//sourceId:79039_1
            retData.setCycleConfName(omsEvaCycleConf_1.getCycleConfName());//SimpleFieldAssign//sourceId:100102_1
            retData.setSubjectLifeCycle(omsEvaCycleConf_1.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:100103_1
            retData.setCycleTypeCode(omsEvaCycleConf_1.getCycleTypeCode());//SimpleFieldAssign//sourceId:79040_1
            retData.setFillinTimeRuleCode(omsEvaCycleConf_1.getFillinTimeRuleCode());//SimpleFieldAssign//sourceId:79041_1
            retData.setEvaTimeRuleCode(omsEvaCycleConf_1.getEvaTimeRuleCode());//SimpleFieldAssign//sourceId:79042_1
            retData.setIsWorkCycle(omsEvaCycleConf_1.getIsWorkCycle());//SimpleFieldAssign//sourceId:79043_1
            retData.setIsFillCycle(omsEvaCycleConf_1.getIsFillCycle());//SimpleFieldAssign//sourceId:79044_1
            retData.setIsEvaCycle(omsEvaCycleConf_1.getIsEvaCycle());//SimpleFieldAssign//sourceId:79045_1
            retData.setIsWarningCycle(omsEvaCycleConf_1.getIsWarningCycle());//SimpleFieldAssign//sourceId:79046_1
            retData.setIsResultCycle(omsEvaCycleConf_1.getIsResultCycle());//SimpleFieldAssign//sourceId:79047_1
            retData.setIsLastCycle(omsEvaCycleConf_1.getIsLastCycle());//SimpleFieldAssign//sourceId:79048_1
            retData.setOperationInductionId(omsEvaCycleConf_1.getOperationInductionId());//SimpleFieldAssign//sourceId:79146_1
            retData.setOperateTime(omsEvaCycleConf_1.getOperateTime());//SimpleFieldAssign//sourceId:79147_1
        }
        if (omsCycleType_1 != null) {
            retData.setCycleTypeName(omsCycleType_1.getCycleTypeName());//SimpleFieldAssign//sourceId:376548_1
        }


        return retData;
    }

    /**
     * D3-2查周期配置列表[2555]
     * gen by moon at 8/17/2022, 8:02:24 PM
     */
    @Trace(operationName = "D3-2查周期配置列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryCycleConfListRespDto queryCycleConfList(QueryCycleConfListReqDto reqDto) {


        List<OmsEvaCycleConf> listOmsEvaCycleConf_1 = new ArrayList<>();
//步骤0: 3-2-08查周期配置列表 - queryCycleConfList
        List<OmsEvaCycleConf> listOmsEvaCycleConf = new ArrayList<>();
        QueryCycleConfListReq queryCycleConfListReq = new QueryCycleConfListReq();
        if (reqDto != null) {
            queryCycleConfListReq.setIsArchive(reqDto.getIsArchive());//sourceId:79017_1
        }

        /*3-2-08查周期配置列表[2539]   */

        listOmsEvaCycleConf = mOmsEvaCycleConfService.queryCycleConfList(queryCycleConfListReq);

        listOmsEvaCycleConf_1 = listOmsEvaCycleConf;

        QueryCycleConfListRespDto retData = new QueryCycleConfListRespDto();
        retData.setCycleConfList(listOmsEvaCycleConf_1.stream().map(item -> BeanUtil.toBean(item, CycleConfDto.class)).collect(Collectors.toList()));//sourceId:79020_1


        return retData;
    }

    /**
     * D3-2修改周期配置[2554]
     * gen by moon at 8/10/2022, 3:28:23 AM
     */
    @Trace(operationName = "D3-2修改周期配置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UpdateCycleConfRespDto updateCycleConf(UpdateCycleConfReqDto reqDto) {


        //步骤0: 3-2-08修改周期配置 - updateCycleConf
        boolean bOOLEAN;
        OmsEvaCycleConf omsEvaCycleConf = new OmsEvaCycleConf();
        if (reqDto != null) {
            omsEvaCycleConf.setCycleConfId(reqDto.getCycleConfId());//sourceId:103395_1
            omsEvaCycleConf.setCycleConfName(reqDto.getCycleConfName());//sourceId:103384_1
            omsEvaCycleConf.setCycleConfCode(reqDto.getCycleConfCode());//sourceId:103382_1
            omsEvaCycleConf.setCycleTypeCode(reqDto.getCycleTypeCode());//sourceId:103383_1
            omsEvaCycleConf.setFillinTimeRuleCode(reqDto.getFillinTimeRuleCode());//sourceId:103385_1
            omsEvaCycleConf.setEvaTimeRuleCode(reqDto.getEvaTimeRuleCode());//sourceId:103386_1
            omsEvaCycleConf.setIsFillCycle(reqDto.getIsFillCycle());//sourceId:103387_1
            omsEvaCycleConf.setIsEvaCycle(reqDto.getIsEvaCycle());//sourceId:103388_1
            omsEvaCycleConf.setIsWarningCycle(reqDto.getIsWarningCycle());//sourceId:103389_1
            omsEvaCycleConf.setIsWorkCycle(reqDto.getIsWorkCycle());//sourceId:103390_1
            omsEvaCycleConf.setIsLastCycle(reqDto.getIsLastCycle());//sourceId:103391_1
            omsEvaCycleConf.setIsResultCycle(reqDto.getIsResultCycle());//sourceId:103392_1
            omsEvaCycleConf.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:103393_1
        }

        /*3-2-08修改周期配置[2538]   */
        Assert.isNull(omsEvaCycleConf.getCycleConfId(), "D3-2修改周期配置-3-2-08修改周期配置-周期配置ID不能为空", false);
        bOOLEAN = mOmsEvaCycleConfService.updateCycleConf(omsEvaCycleConf);


        UpdateCycleConfRespDto retData = new UpdateCycleConfRespDto();


        return retData;
    }

    /**
     * D3-2新增周期配置[2553]
     * gen by moon at 8/10/2022, 3:28:22 AM
     */
    @Trace(operationName = "D3-2新增周期配置")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddCycleConfRespDto addCycleConf(AddCycleConfReqDto reqDto) {


        String string_1 = null;
//步骤0: 3-2-08新增周期配置 - addCycleConf
        String string = null;
        OmsEvaCycleConf omsEvaCycleConf = new OmsEvaCycleConf();
        if (reqDto != null) {
            omsEvaCycleConf.setCycleConfName(reqDto.getCycleConfName());//sourceId:114326_1
            omsEvaCycleConf.setCycleConfCode(reqDto.getCycleConfCode());//sourceId:78973_1
            omsEvaCycleConf.setCycleTypeCode(reqDto.getCycleTypeCode());//sourceId:78974_1
            omsEvaCycleConf.setFillinTimeRuleCode(reqDto.getFillinTimeRuleCode());//sourceId:78975_1
            omsEvaCycleConf.setEvaTimeRuleCode(reqDto.getEvaTimeRuleCode());//sourceId:78976_1
            omsEvaCycleConf.setIsFillCycle(reqDto.getIsFillCycle());//sourceId:78977_1
            omsEvaCycleConf.setIsEvaCycle(reqDto.getIsEvaCycle());//sourceId:78978_1
            omsEvaCycleConf.setIsWarningCycle(reqDto.getIsWarningCycle());//sourceId:78979_1
            omsEvaCycleConf.setIsWorkCycle(reqDto.getIsWorkCycle());//sourceId:78980_1
            omsEvaCycleConf.setIsLastCycle(reqDto.getIsLastCycle());//sourceId:78981_1
            omsEvaCycleConf.setIsResultCycle(reqDto.getIsResultCycle());//sourceId:78982_1
            omsEvaCycleConf.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:78983_1
        }

        /*3-2-08新增周期配置[2537]   */
        Assert.isNull(omsEvaCycleConf.getCycleConfName(), "D3-2新增周期配置-3-2-08新增周期配置-周期配置名称不能为空", false);
        Assert.isNull(omsEvaCycleConf.getCycleConfCode(), "D3-2新增周期配置-3-2-08新增周期配置-周期配置标识不能为空", false);
        Assert.isNull(omsEvaCycleConf.getCycleTypeCode(), "D3-2新增周期配置-3-2-08新增周期配置-周期类型标识不能为空", false);
        Assert.isNull(omsEvaCycleConf.getFillinTimeRuleCode(), "D3-2新增周期配置-3-2-08新增周期配置-填报时段规则标识不能为空", false);
        Assert.isNull(omsEvaCycleConf.getEvaTimeRuleCode(), "D3-2新增周期配置-3-2-08新增周期配置-评价时段规则标识不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsFillCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否填报周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsEvaCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否评价周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsWarningCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否预警周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsWorkCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否工作周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsLastCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否末级周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getIsResultCycle(), "D3-2新增周期配置-3-2-08新增周期配置-是否结果周期不能为空", false);
        Assert.isNull(omsEvaCycleConf.getSubjectLifeCycle(), "D3-2新增周期配置-3-2-08新增周期配置-主体生命周期不能为空", false);
        string = mOmsEvaCycleConfService.addCycleConf(omsEvaCycleConf);

        string_1 = string;

        AddCycleConfRespDto retData = new AddCycleConfRespDto();
        if (string_1 != null) {
            retData.setCycleConfId(string_1);//sourceId:103439_1
        }


        return retData;
    }

    /**
     * D3-4查时段规则详情[2548]
     * gen by moon at 8/10/2022, 3:28:21 AM
     */
    @Trace(operationName = "D3-4查时段规则详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryCycleTimeRuleDetailRespDto queryCycleTimeRuleDetail(QueryCycleTimeRuleDetailReqDto reqDto) {


        OmsCycleTimeRule omsCycleTimeRule_1 = null;
//步骤0: 3-4-05查时段规则详情 - queryCycleTimeRuleDetail
        OmsCycleTimeRule omsCycleTimeRule = null;
        QueryCycleTimeRuleDetailReq queryCycleTimeRuleDetailReq = new QueryCycleTimeRuleDetailReq();
        if (reqDto != null) {
            queryCycleTimeRuleDetailReq.setTimeRuleId(reqDto.getTimeRuleId());//sourceId:79206_1
            queryCycleTimeRuleDetailReq.setTimeRuleCode(reqDto.getTimeRuleCode());//sourceId:79207_1
            queryCycleTimeRuleDetailReq.setIsArchive(reqDto.getIsArchive());//sourceId:103445_1
        }

        /*3-4-05查时段规则详情[2361]   */

        omsCycleTimeRule = mOmsCycleTimeRuleService.queryCycleTimeRuleDetail(queryCycleTimeRuleDetailReq);

        omsCycleTimeRule_1 = omsCycleTimeRule;

        QueryCycleTimeRuleDetailRespDto retData = new QueryCycleTimeRuleDetailRespDto();
        if (omsCycleTimeRule_1 != null) {
            retData.setTimeRuleId(omsCycleTimeRule_1.getTimeRuleId());//sourceId:79232_1
            retData.setTimeRuleCode(omsCycleTimeRule_1.getTimeRuleCode());//sourceId:79233_1
            retData.setTimeRuleName(omsCycleTimeRule_1.getTimeRuleName());//sourceId:79234_1
            retData.setTimeRelativeNumber(omsCycleTimeRule_1.getTimeRelativeNumber());//sourceId:79235_1
            retData.setTimeNumber(omsCycleTimeRule_1.getTimeNumber());//sourceId:79236_1
            retData.setFollowTimeNumber(omsCycleTimeRule_1.getFollowTimeNumber());//sourceId:79237_1
            retData.setTimeUnit(omsCycleTimeRule_1.getTimeUnit());//sourceId:79238_1
            retData.setCalculateType(omsCycleTimeRule_1.getCalculateType());//sourceId:79239_1
            retData.setStartStopType(omsCycleTimeRule_1.getStartStopType());//sourceId:79240_1
            retData.setIsContains(omsCycleTimeRule_1.getIsContains());//sourceId:79241_1
            retData.setSubjectLifeCycle(omsCycleTimeRule_1.getSubjectLifeCycle());//sourceId:79242_1
            retData.setOperationInductionId(omsCycleTimeRule_1.getOperationInductionId());//sourceId:79244_1
            retData.setOperateTime(omsCycleTimeRule_1.getOperateTime());//sourceId:79248_1
            retData.setPeriodRuleType(omsCycleTimeRule_1.getPeriodRuleType());//sourceId:173606_1
        }


        return retData;
    }

    /**
     * D3-4查时段规则列表[2547]
     * gen by moon at 8/10/2022, 3:28:19 AM
     */
    @Trace(operationName = "D3-4查时段规则列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryCycleTimeRuleListRespDto queryCycleTimeRuleList(QueryCycleTimeRuleListReqDto reqDto) {


        List<OmsCycleTimeRule> listOmsCycleTimeRule_1 = new ArrayList<>();
//步骤0: 3-4-05查时段规则列表 - queryCycleTimeRuleList
        List<OmsCycleTimeRule> listOmsCycleTimeRule = new ArrayList<>();
        QueryCycleTimeRuleListReq queryCycleTimeRuleListReq = new QueryCycleTimeRuleListReq();
        if (reqDto != null) {
            queryCycleTimeRuleListReq.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79200_1
            queryCycleTimeRuleListReq.setIsArchive(reqDto.getIsArchive());//sourceId:79201_1
            queryCycleTimeRuleListReq.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:103376_1
        }

        /*3-4-05查时段规则列表[2529]   */

        listOmsCycleTimeRule = mOmsCycleTimeRuleService.queryCycleTimeRuleList(queryCycleTimeRuleListReq);

        listOmsCycleTimeRule_1 = listOmsCycleTimeRule;

        QueryCycleTimeRuleListRespDto retData = new QueryCycleTimeRuleListRespDto();
        retData.setCycleTimeRuleList(listOmsCycleTimeRule_1.stream().map(item -> BeanUtil.toBean(item, CycleTimeRuleDto.class)).collect(Collectors.toList()));//sourceId:79205_1


        return retData;
    }

    /**
     * D3-4修改时段规则[2546]
     * gen by moon at 8/10/2022, 3:28:18 AM
     */
    @Trace(operationName = "D3-4修改时段规则")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UpdateCycleTimeRuleRespDto updateCycleTimeRule(UpdateCycleTimeRuleReqDto reqDto) {


        //步骤0: 3-4-05修改时段规则 - updateCycleTimeRule
        boolean bOOLEAN;
        OmsCycleTimeRule omsCycleTimeRule = new OmsCycleTimeRule();
        if (reqDto != null) {
            omsCycleTimeRule.setTimeRuleId(reqDto.getTimeRuleId());//sourceId:103452_1
            omsCycleTimeRule.setTimeRuleName(reqDto.getTimeRuleName());//sourceId:79179_1
            omsCycleTimeRule.setTimeRuleCode(reqDto.getTimeRuleCode());//sourceId:79178_1
            omsCycleTimeRule.setStartStopType(reqDto.getStartStopType());//sourceId:79186_1
            omsCycleTimeRule.setIsContains(reqDto.getIsContains());//sourceId:79187_1
            omsCycleTimeRule.setTimeUnit(reqDto.getTimeUnit());//sourceId:79184_1
            omsCycleTimeRule.setCalculateType(reqDto.getCalculateType());//sourceId:79185_1
            omsCycleTimeRule.setTimeRelativeNumber(reqDto.getTimeRelativeNumber());//sourceId:79181_1
            omsCycleTimeRule.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79180_1
            omsCycleTimeRule.setTimeNumber(reqDto.getTimeNumber());//sourceId:79182_1
            omsCycleTimeRule.setFollowTimeNumber(reqDto.getFollowTimeNumber());//sourceId:79183_1
            omsCycleTimeRule.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:79188_1
        }

        /*3-4-05修改时段规则[2528]   */
        Assert.isNull(omsCycleTimeRule.getTimeRuleId(), "D3-4修改时段规则-3-4-05修改时段规则-时段规则ID不能为空", false);
        bOOLEAN = mOmsCycleTimeRuleService.updateCycleTimeRule(omsCycleTimeRule);


        UpdateCycleTimeRuleRespDto retData = new UpdateCycleTimeRuleRespDto();


        return retData;
    }

    /**
     * D3-4新增时段规则[2545]
     * gen by moon at 8/10/2022, 3:28:18 AM
     */
    @Trace(operationName = "D3-4新增时段规则")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddCycleTimeRuleRespDto addCycleTimeRule(AddCycleTimeRuleReqDto reqDto) {


        String string_1 = null;
//步骤0: 3-4-05新增时段规则 - addCycleTimeRule
        String string = null;
        OmsCycleTimeRule omsCycleTimeRule = new OmsCycleTimeRule();
        if (reqDto != null) {
            omsCycleTimeRule.setTimeRuleName(reqDto.getTimeRuleName());//sourceId:79156_1
            omsCycleTimeRule.setTimeRuleCode(reqDto.getTimeRuleCode());//sourceId:79155_1
            omsCycleTimeRule.setPeriodRuleType(reqDto.getPeriodRuleType());//sourceId:79157_1
            omsCycleTimeRule.setStartStopType(reqDto.getStartStopType());//sourceId:79163_1
            omsCycleTimeRule.setIsContains(reqDto.getIsContains());//sourceId:79164_1
            omsCycleTimeRule.setTimeUnit(reqDto.getTimeUnit());//sourceId:79161_1
            omsCycleTimeRule.setCalculateType(reqDto.getCalculateType());//sourceId:79162_1
            omsCycleTimeRule.setTimeRelativeNumber(reqDto.getTimeRelativeNumber());//sourceId:79158_1
            omsCycleTimeRule.setTimeNumber(reqDto.getTimeNumber());//sourceId:79159_1
            omsCycleTimeRule.setFollowTimeNumber(reqDto.getFollowTimeNumber());//sourceId:79160_1
            omsCycleTimeRule.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:79165_1
        }

        /*3-4-05新增时段规则[2527]   */
        Assert.isNull(omsCycleTimeRule.getTimeRuleName(), "D3-4新增时段规则-3-4-05新增时段规则-时段规则名称不能为空", false);
        Assert.isNull(omsCycleTimeRule.getTimeRuleCode(), "D3-4新增时段规则-3-4-05新增时段规则-时段规则标识不能为空", false);
        Assert.isNull(omsCycleTimeRule.getPeriodRuleType(), "D3-4新增时段规则-3-4-05新增时段规则-时段规则类型不能为空", false);
        Assert.isNull(omsCycleTimeRule.getStartStopType(), "D3-4新增时段规则-3-4-05新增时段规则-参照哪一天不能为空", false);
        Assert.isNull(omsCycleTimeRule.getIsContains(), "D3-4新增时段规则-3-4-05新增时段规则-是否包含参照这一天不能为空", false);
        Assert.isNull(omsCycleTimeRule.getTimeUnit(), "D3-4新增时段规则-3-4-05新增时段规则-时间单位不能为空", false);
        Assert.isNull(omsCycleTimeRule.getCalculateType(), "D3-4新增时段规则-3-4-05新增时段规则-计算类型不能为空", false);
        Assert.isNull(omsCycleTimeRule.getTimeRelativeNumber(), "D3-4新增时段规则-3-4-05新增时段规则-相对周期提前或延后数量 不能为空", false);
        Assert.isNull(omsCycleTimeRule.getTimeNumber(), "D3-4新增时段规则-3-4-05新增时段规则-时段区间数量不能为空", false);
        Assert.isNull(omsCycleTimeRule.getSubjectLifeCycle(), "D3-4新增时段规则-3-4-05新增时段规则-主体生命周期不能为空", false);
        string = mOmsCycleTimeRuleService.addCycleTimeRule(omsCycleTimeRule);

        string_1 = string;

        AddCycleTimeRuleRespDto retData = new AddCycleTimeRuleRespDto();
        if (string_1 != null) {
            retData.setTimeRuleId(string_1);//sourceId:103456_1
        }


        return retData;
    }

    /**
     * D3-2时段规则分析4个时间点(公共)[3519]
     * gen by moon at 5/7/2024, 11:17:20 PM
     */
    @Trace(operationName = "D3-2时段规则分析4个时间点(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ObtainCycleTimeRuleInfoComRespDto obtainCycleTimeRuleInfoCom(ObtainCycleTimeRuleInfoComReqDto reqDto) {


        ImplementCountTimeRulesTimeRespDto cycleShiftRes_1 = null;
        ObtainReceiveFieldRespDto receptionServiceRes_1 = null;
//virtualUsage 3-4-05查填报时段规则标识（用于计算时段规则时间）  17888
        OmsCycleTimeRule omsCycleTimeRule = null;
        QueryCycleTimeRuleDetailReq queryCycleTimeRuleDetailReq = new QueryCycleTimeRuleDetailReq();
        queryCycleTimeRuleDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:153006_1_17888
        if (reqDto != null) {
            queryCycleTimeRuleDetailReq.setTimeRuleCode(reqDto.getTimeRuleCode());//SimpleFieldAssign//sourceId:152991_1_17888
        }

        /*3-4-05查填报时段规则标识（用于计算时段规则时间）[2361]   */
        Assert.isNull(queryCycleTimeRuleDetailReq.getTimeRuleCode(), "D3-2时段规则分析4个时间点(公共)-3-4-05查填报时段规则标识（用于计算时段规则时间）-时段规则标识不能为空", false);
        Assert.isNull(queryCycleTimeRuleDetailReq.getSubjectLifeCycle(), "D3-2时段规则分析4个时间点(公共)-3-4-05查填报时段规则标识（用于计算时段规则时间）-主体生命周期不能为空", false);
        omsCycleTimeRule = mOmsCycleTimeRuleService.queryCycleTimeRuleDetail(queryCycleTimeRuleDetailReq)/*vcase invoke 本地 method 方法调用;*/;
        Assert.isTrue(omsCycleTimeRule == null || omsCycleTimeRule.getTimeRuleId() == null, "找不到数据，系统异常", false);


//virtualUsage D3-判断执行周期是否完整(公共)  25147
        JudgeExecuteCycleStageIsIntactComRespDto judgeExecuteCycleStageIsIntactComRespDto = null;
        JudgeExecuteCycleStageIsIntactComReqDto judgeExecuteCycleStageIsIntactComReqDto = new JudgeExecuteCycleStageIsIntactComReqDto();
        if (reqDto != null) {
            judgeExecuteCycleStageIsIntactComReqDto.setExecuteCycleStageId(reqDto.getExecuteCycleStageId());//SimpleFieldAssign//sourceId:517057_1_25147
            judgeExecuteCycleStageIsIntactComReqDto.setCycleId(reqDto.getCycleId());//SimpleFieldAssign//sourceId:517058_1_25147
            judgeExecuteCycleStageIsIntactComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:517059_1_25147
        }

        /*D3-判断执行周期是否完整(公共)[5465]   */
        Assert.isNull(judgeExecuteCycleStageIsIntactComReqDto.getExecuteCycleStageId(), "D3-2时段规则分析4个时间点(公共)-D3-判断执行周期是否完整(公共)-执行周期阶段ID不能为空", false);
        Assert.isNull(judgeExecuteCycleStageIsIntactComReqDto.getCycleId(), "D3-2时段规则分析4个时间点(公共)-D3-判断执行周期是否完整(公共)-周期ID不能为空", false);
        Assert.isNull(judgeExecuteCycleStageIsIntactComReqDto.getEvaluationTemplateId(), "D3-2时段规则分析4个时间点(公共)-D3-判断执行周期是否完整(公共)-冗余评价模板ID不能为空", false);
        judgeExecuteCycleStageIsIntactComRespDto = targetCycleService.judgeExecuteCycleStageIsIntactCom(judgeExecuteCycleStageIsIntactComReqDto)/*vcase invoke isSameApp*/;


        if ((omsCycleTimeRule != null && omsCycleTimeRule.getStartStopType() != null && omsCycleTimeRule.getStartStopType().equals("LAST_DAY_CYCLE") && judgeExecuteCycleStageIsIntactComRespDto != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField() != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField().equals("TRUE"))) {
            //if((3-4-05查填报时段规则标识（用于计算时段规则时间）.参照哪一天 等于 周期最后一天 and D3-判断执行周期是否完整(公共).执行周期是否完整 等于 是))  17889

            OmsCycle omsCycle = null;
            QueryCycleDetailReq queryCycleDetailReq = new QueryCycleDetailReq();
            queryCycleDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:358900_1_17891
            if (reqDto != null) {
                queryCycleDetailReq.setCycleId(reqDto.getCycleId());//SimpleFieldAssign//sourceId:358899_1_17891
            }

            /*3-4-04查询周期详情[2004]   */
            Assert.isNull(queryCycleDetailReq.getCycleId(), "D3-2时段规则分析4个时间点(公共)-3-4-04查询周期详情-周期ID不能为空", false);
            Assert.isNull(queryCycleDetailReq.getSubjectLifeCycle(), "D3-2时段规则分析4个时间点(公共)-3-4-04查询周期详情-主体生命周期不能为空", false);
            omsCycle = mOmsCycleService.queryCycleDetail(queryCycleDetailReq)/*vcase invoke 本地 method 方法调用;*/;


//ModelCode: cycleShift
            ImplementCountTimeRulesTimeRespDto cycleShiftRes = null;
            if (omsCycleTimeRule != null && omsCycle != null) {
                ImplementCountTimeRulesTimeReqDto cycleShiftReq = new ImplementCountTimeRulesTimeReqDto();
                if (omsCycleTimeRule != null) {
                    cycleShiftReq.setTimeRelativeNumber(omsCycleTimeRule.getTimeRelativeNumber());//SimpleFieldAssign//sourceId:153015_1_17893
                    cycleShiftReq.setTimeNumber(omsCycleTimeRule.getTimeNumber());//SimpleFieldAssign//sourceId:153025_1_17893
                    cycleShiftReq.setFollowTimeNumber(omsCycleTimeRule.getFollowTimeNumber());//SimpleFieldAssign//sourceId:153026_1_17893
                    cycleShiftReq.setStartStopType(omsCycleTimeRule.getStartStopType());//SimpleFieldAssign//sourceId:153018_1_17893
                    cycleShiftReq.setIsContains(omsCycleTimeRule.getIsContains());//SimpleFieldAssign//sourceId:153019_1_17893
                    cycleShiftReq.setCalculateType(omsCycleTimeRule.getCalculateType());//SimpleFieldAssign//sourceId:153017_1_17893
                    cycleShiftReq.setTimeUnit(omsCycleTimeRule.getTimeUnit());//SimpleFieldAssign//sourceId:153016_1_17893
                }
                if (omsCycle != null) {
                    cycleShiftReq.setReferenceCycleTime(omsCycle.getCycleEndTime());//SimpleFieldAssign//sourceId:153020_1_17893
                }

                /*M3执行计算时段规则时间（特殊方法）[2365]  入参时间字段，偏移数（正整数），正向偏移或反向偏移 */
                Assert.isNull(cycleShiftReq.getTimeRelativeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-相对周期提前或延后数量 不能为空", false);
                Assert.isNull(cycleShiftReq.getTimeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-时段区间数量不能为空", false);
                Assert.isNull(cycleShiftReq.getFollowTimeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-跟随时段区间数量不能为空", false);
                Assert.isNull(cycleShiftReq.getReferenceCycleTime(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-参照周期时间不能为空", false);
                Assert.isNull(cycleShiftReq.getStartStopType(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-参照哪一天不能为空", false);
                Assert.isNull(cycleShiftReq.getIsContains(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-是否包含参照这一天不能为空", false);
                Assert.isNull(cycleShiftReq.getCalculateType(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-计算类型不能为空", false);
                Assert.isNull(cycleShiftReq.getTimeUnit(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-时间单位不能为空", false);
                cycleShiftRes = nbCycleConf.implementCountTimeRulesTime(cycleShiftReq);


                cycleShiftRes_1 = cycleShiftRes;
            }
//processBranchName:正常结束 ,processBranchId:17892

        } else if ((omsCycleTimeRule != null && omsCycleTimeRule.getStartStopType() != null && omsCycleTimeRule.getStartStopType().equals("FIRST_DAT_CYCLE") && judgeExecuteCycleStageIsIntactComRespDto != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField() != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField().equals("TRUE"))) {
            //elseif((3-4-05查填报时段规则标识（用于计算时段规则时间）.参照哪一天 等于 周期第一天 and D3-判断执行周期是否完整(公共).执行周期是否完整 等于 是))  17898

//ModelCode: getLastAndNextCycle
            ObtainGetNextCycleRespDto getLastAndNextCycleRes = null;
            ObtainGetNextCycleReqDto getLastAndNextCycleReq = new ObtainGetNextCycleReqDto();
            if (reqDto != null && reqDto.getExecuteCycleStageList() != null && !CollectionUtil.isEmpty(reqDto.getExecuteCycleStageList())) {
                getLastAndNextCycleReq.setExecuteCycleStageList(reqDto.getExecuteCycleStageList().stream().map(item -> BeanUtil.toBean(item, ExecuteCycleStageDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:358933_1_17899
            }
            if (reqDto != null) {
                getLastAndNextCycleReq.setCycleId(reqDto.getCycleId());//SimpleFieldAssign//sourceId:358934_1_17899
                getLastAndNextCycleReq.setCycleTypeCode(reqDto.getCycleTypeCode());//SimpleFieldAssign//sourceId:358935_1_17899
            }

            /*M3-获取获取当前周期下一个周期（特殊方法）[4754]  入参：当前时间，数据集【周期ID、周期开始时间、周期结束时间】 逻辑：根据当前时间与数据集中数据开始时间、结束时间比较，获取当前周期ID以及下一个周期ID、上一个周期ID 出参：当前周期ID、下一个周期ID、上一个周期ID */
            Assert.isNull(getLastAndNextCycleReq.getCycleId(), "D3-2时段规则分析4个时间点(公共)-M3-获取获取当前周期下一个周期（特殊方法）-周期ID不能为空", false);
            Assert.isNull(getLastAndNextCycleReq.getCycleTypeCode(), "D3-2时段规则分析4个时间点(公共)-M3-获取获取当前周期下一个周期（特殊方法）-周期类型标识不能为空", false);
            getLastAndNextCycleRes = nbCycleConf.obtainGetNextCycle(getLastAndNextCycleReq);


            OmsCycle omsCycle_2 = null;
            QueryCycleDetailReq queryCycleDetailReq_1 = new QueryCycleDetailReq();
            queryCycleDetailReq_1.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:358900_1_17900
            if (getLastAndNextCycleRes != null) {
                queryCycleDetailReq_1.setCycleId(getLastAndNextCycleRes.getCycleId());//SimpleFieldAssign//sourceId:358899_1_17900
            }

            /*3-4-04查询周期详情[2004]   */
            Assert.isNull(queryCycleDetailReq_1.getCycleId(), "D3-2时段规则分析4个时间点(公共)-3-4-04查询周期详情-周期ID不能为空", false);
            Assert.isNull(queryCycleDetailReq_1.getSubjectLifeCycle(), "D3-2时段规则分析4个时间点(公共)-3-4-04查询周期详情-主体生命周期不能为空", false);
            omsCycle_2 = mOmsCycleService.queryCycleDetail(queryCycleDetailReq_1)/*vcase invoke 本地 method 方法调用;*/;


//ModelCode: cycleShift
            ImplementCountTimeRulesTimeRespDto cycleShiftRes_2 = null;
            if (omsCycleTimeRule != null && omsCycle_2 != null) {
                ImplementCountTimeRulesTimeReqDto cycleShiftReq_1 = new ImplementCountTimeRulesTimeReqDto();
                if (omsCycleTimeRule != null) {
                    cycleShiftReq_1.setTimeRelativeNumber(omsCycleTimeRule.getTimeRelativeNumber());//SimpleFieldAssign//sourceId:153015_1_17901
                    cycleShiftReq_1.setTimeNumber(omsCycleTimeRule.getTimeNumber());//SimpleFieldAssign//sourceId:153025_1_17901
                    cycleShiftReq_1.setFollowTimeNumber(omsCycleTimeRule.getFollowTimeNumber());//SimpleFieldAssign//sourceId:153026_1_17901
                    cycleShiftReq_1.setStartStopType(omsCycleTimeRule.getStartStopType());//SimpleFieldAssign//sourceId:153018_1_17901
                    cycleShiftReq_1.setIsContains(omsCycleTimeRule.getIsContains());//SimpleFieldAssign//sourceId:153019_1_17901
                    cycleShiftReq_1.setCalculateType(omsCycleTimeRule.getCalculateType());//SimpleFieldAssign//sourceId:153017_1_17901
                    cycleShiftReq_1.setTimeUnit(omsCycleTimeRule.getTimeUnit());//SimpleFieldAssign//sourceId:153016_1_17901
                }
                if (omsCycle_2 != null) {
                    cycleShiftReq_1.setReferenceCycleTime(omsCycle_2.getCycleStartTime());//SimpleFieldAssign//sourceId:153020_1_17901
                }

                /*M3执行计算时段规则时间（特殊方法）[2365]  入参时间字段，偏移数（正整数），正向偏移或反向偏移 */
                Assert.isNull(cycleShiftReq_1.getTimeRelativeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-相对周期提前或延后数量 不能为空", false);
                Assert.isNull(cycleShiftReq_1.getTimeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-时段区间数量不能为空", false);
                Assert.isNull(cycleShiftReq_1.getFollowTimeNumber(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-跟随时段区间数量不能为空", false);
                Assert.isNull(cycleShiftReq_1.getReferenceCycleTime(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-参照周期时间不能为空", false);
                Assert.isNull(cycleShiftReq_1.getStartStopType(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-参照哪一天不能为空", false);
                Assert.isNull(cycleShiftReq_1.getIsContains(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-是否包含参照这一天不能为空", false);
                Assert.isNull(cycleShiftReq_1.getCalculateType(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-计算类型不能为空", false);
                Assert.isNull(cycleShiftReq_1.getTimeUnit(), "D3-2时段规则分析4个时间点(公共)-M3执行计算时段规则时间（特殊方法）-时间单位不能为空", false);
                cycleShiftRes_2 = nbCycleConf.implementCountTimeRulesTime(cycleShiftReq_1);


                cycleShiftRes_1 = cycleShiftRes_2;
            }
//processBranchName:正常结束 ,processBranchId:17902

        } else if ((judgeExecuteCycleStageIsIntactComRespDto != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField() != null && judgeExecuteCycleStageIsIntactComRespDto.getComTxtField().equals("FALSE"))) {
            //elseif(D3-判断执行周期是否完整(公共).执行周期是否完整 等于 否)  25653

            OmsExecuteCycleStage omsExecuteCycleStage = null;
            QueryExecuteCycleStageDetailReq queryExecuteCycleStageDetailReq = new QueryExecuteCycleStageDetailReq();
            queryExecuteCycleStageDetailReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:548788_1_25740
            if (reqDto != null) {
                queryExecuteCycleStageDetailReq.setExecuteCycleStageId(reqDto.getExecuteCycleStageId());//SimpleFieldAssign//sourceId:548784_1_25740
                queryExecuteCycleStageDetailReq.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:548789_1_25740
            }

            /*3-3-07查询执行周期阶段详情[2429]   */
            Assert.isNull(queryExecuteCycleStageDetailReq.getExecuteCycleStageId(), "D3-2时段规则分析4个时间点(公共)-3-3-07查询执行周期阶段详情-执行周期阶段ID不能为空", false);
            Assert.isNull(queryExecuteCycleStageDetailReq.getSubjectLifeCycle(), "D3-2时段规则分析4个时间点(公共)-3-3-07查询执行周期阶段详情-主体生命周期不能为空", false);
            Assert.isNull(queryExecuteCycleStageDetailReq.getEvaluationTemplateId(), "D3-2时段规则分析4个时间点(公共)-3-3-07查询执行周期阶段详情-评价模板ID不能为空", false);
            omsExecuteCycleStage = mOmsExecuteCycleStageService.queryExecuteCycleStageDetail(queryExecuteCycleStageDetailReq)/*vcase invoke 本地 method 方法调用;*/;


//ModelCode: receptionService
            ObtainReceiveFieldRespDto receptionServiceRes = null;
            if (omsExecuteCycleStage != null) {
                ObtainReceiveFieldReqDto receptionServiceReq = new ObtainReceiveFieldReqDto();
                if (omsExecuteCycleStage != null) {
                    receptionServiceReq.setTimePeriodStartTime(omsExecuteCycleStage.getCycleStartTime());//SimpleFieldAssign//sourceId:659095_1_25655
                    receptionServiceReq.setTimePeriodEndTime(omsExecuteCycleStage.getCycleEndTime());//SimpleFieldAssign//sourceId:659096_1_25655
                    receptionServiceReq.setFollowTimePeriodStartTime(omsExecuteCycleStage.getCycleStartTime());//SimpleFieldAssign//sourceId:548792_1_25655
                    receptionServiceReq.setFollowTimePeriodEndTime(omsExecuteCycleStage.getCycleEndTime());//SimpleFieldAssign//sourceId:548793_1_25655
                }

                /*约定填报、评价时段[2451]  用于特殊方法接收上游入参。 */

                receptionServiceRes = nbCycleConf.obtainReceiveField(receptionServiceReq);


                receptionServiceRes_1 = receptionServiceRes;
            }
//processBranchName:正常结束 ,processBranchId:25656

        }
        ObtainCycleTimeRuleInfoComRespDto retData = new ObtainCycleTimeRuleInfoComRespDto();
        if (receptionServiceRes_1 != null) {
            retData.setTimePeriodStartTime(receptionServiceRes_1.getTimePeriodStartTime());//SimpleFieldAssign//sourceId:659097_1
            retData.setTimePeriodEndTime(receptionServiceRes_1.getTimePeriodEndTime());//SimpleFieldAssign//sourceId:659098_1
            retData.setFollowTimePeriodStartTime(receptionServiceRes_1.getFollowTimePeriodStartTime());//SimpleFieldAssign//sourceId:153032_1
            retData.setFollowTimePeriodEndTime(receptionServiceRes_1.getFollowTimePeriodEndTime());//SimpleFieldAssign//sourceId:153033_1
        }
        if (cycleShiftRes_1 != null) {
            retData.setTimePeriodStartTime(cycleShiftRes_1.getTimePeriodStartTime());//SimpleFieldAssign//sourceId:659097_1
            retData.setTimePeriodEndTime(cycleShiftRes_1.getTimePeriodEndTime());//SimpleFieldAssign//sourceId:659098_1
            retData.setFollowTimePeriodStartTime(cycleShiftRes_1.getFollowTimePeriodStartTime());//SimpleFieldAssign//sourceId:153032_1
            retData.setFollowTimePeriodEndTime(cycleShiftRes_1.getFollowTimePeriodEndTime());//SimpleFieldAssign//sourceId:153033_1
        }


        return retData;
    }
    //
}
